package com.phospherus.flow.service

import com.phospherus.common.service.impl.BaseServiceImpl
import com.phospherus.flow.entity.FlowNode
import com.phospherus.flow.repository.FlowNodeRepository
import org.springframework.stereotype.Service

/**
 * @author songjinlong
 * @version 1.0
 * @since 2017/11/10
 */
@Service
class FlowNodeService : BaseServiceImpl<FlowNode, Long, FlowNodeRepository>() {
    fun getChildrenNodes(flowId: Long, currNodeId: Long?): List<FlowNode> {
        var cNodeId = currNodeId
        if (cNodeId == null) {
            cNodeId = getStartNode(flowId).id
        }
        return repository.getChildrenNodes(cNodeId!!)
    }

    fun getStartNode(flowId: Long): FlowNode = repository.getStartNodeByFlowId(flowId)

}
